```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Nginx全面解析 - 高性能Web服务器指南</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4, h5 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            margin-top: 1.5rem;
            margin-bottom: 1rem;
        }
        .hero {
            background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
            color: white;
        }
        .card {
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
        }
        .feature-icon {
            font-size: 2.5rem;
            color: #3b82f6;
            margin-bottom: 1rem;
        }
        .code-block {
            background-color: #2d3748;
            color: #e2e8f0;
            border-radius: 0.375rem;
            position: relative;
        }
        .code-block pre {
            margin: 0;
            padding: 1rem;
            overflow-x: auto;
        }
        .code-block .code-lang {
            position: absolute;
            top: 0;
            right: 0;
            background-color: #4a5568;
            color: white;
            padding: 0.25rem 0.75rem;
            border-bottom-left-radius: 0.375rem;
            font-size: 0.75rem;
        }
        .timeline-item {
            position: relative;
            padding-left: 2.5rem;
            margin-bottom: 2.5rem;
        }
        .timeline-item:before {
            content: "";
            position: absolute;
            left: 0.75rem;
            top: 0;
            height: 100%;
            width: 2px;
            background-color: #e2e8f0;
        }
        .timeline-dot {
            position: absolute;
            left: 0;
            top: 0;
            width: 1.5rem;
            height: 1.5rem;
            border-radius: 9999px;
            background-color: #3b82f6;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
        }
        .timeline-content {
            background-color: white;
            border-radius: 0.5rem;
            padding: 1.25rem;
            box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
        }
        .nav-link {
            position: relative;
            padding: 0.5rem 0;
            color: #4a5568;
            transition: color 0.3s ease;
        }
        .nav-link:hover {
            color: #3b82f6;
        }
        .nav-link.active {
            color: #3b82f6;
            font-weight: 500;
        }
        .nav-link.active:after {
            content: "";
            position: absolute;
            left: 0;
            bottom: 0;
            width: 100%;
            height: 2px;
            background-color: #3b82f6;
        }
        .sidebar {
            position: sticky;
            top: 2rem;
            height: calc(100vh - 4rem);
            overflow-y: auto;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-6xl mx-auto text-center">
            <div class="inline-block px-3 py-1 mb-4 text-sm font-medium text-blue-100 bg-blue-800 rounded-full">
                <i class="fas fa-server mr-2"></i>高性能Web服务器
            </div>
            <h1 class="text-4xl md:text-5xl font-bold mb-6">Nginx全面解析</h1>
            <p class="text-xl md:text-2xl text-blue-100 max-w-3xl mx-auto mb-8">
                探索高性能开源Web服务器的核心原理与实践应用
            </p>
            <div class="flex flex-wrap justify-center gap-4">
                <a href="#overview" class="px-6 py-3 bg-white text-blue-600 font-medium rounded-lg hover:bg-blue-50 transition-colors">
                    <i class="fas fa-book-open mr-2"></i>开始阅读
                </a>
                <a href="#features" class="px-6 py-3 bg-blue-600 bg-opacity-20 text-white font-medium rounded-lg hover:bg-opacity-30 transition-colors">
                    <i class="fas fa-star mr-2"></i>核心特性
                </a>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
        <div class="flex flex-col lg:flex-row gap-8">
            <!-- Sidebar Navigation -->
            <aside class="lg:w-64 flex-shrink-0 hidden lg:block sidebar">
                <div class="bg-white rounded-lg shadow-sm p-4">
                    <h3 class="font-semibold text-lg mb-4 text-gray-800">目录导航</h3>
                    <nav class="space-y-2">
                        <a href="#overview" class="block nav-link active">
                            <i class="fas fa-info-circle mr-2"></i>概述
                        </a>
                        <a href="#features" class="block nav-link">
                            <i class="fas fa-star mr-2"></i>核心特点
                        </a>
                        <a href="#usage" class="block nav-link">
                            <i class="fas fa-cogs mr-2"></i>主要用途
                        </a>
                        <a href="#proxy" class="block nav-link">
                            <i class="fas fa-exchange-alt mr-2"></i>代理机制
                        </a>
                        <a href="#load-balancing" class="block nav-link">
                            <i class="fas fa-balance-scale mr-2"></i>负载均衡
                        </a>
                        <a href="#static-dynamic" class="block nav-link">
                            <i class="fas fa-code mr-2"></i>动静分离
                        </a>
                        <a href="#ha" class="block nav-link">
                            <i class="fas fa-shield-alt mr-2"></i>高可用方案
                        </a>
                        <a href="#process-model" class="block nav-link">
                            <i class="fas fa-project-diagram mr-2"></i>进程模型
                        </a>
                    </nav>
                </div>
                <div class="mt-6 bg-white rounded-lg shadow-sm p-4">
                    <h3 class="font-semibold text-lg mb-4 text-gray-800">快速链接</h3>
                    <div class="space-y-3">
                        <a href="https://nginx.org/" target="_blank" class="flex items-center text-blue-600 hover:text-blue-800">
                            <i class="fas fa-external-link-alt mr-2"></i>官方文档
                        </a>
                        <a href="https://github.com/nginx/nginx" target="_blank" class="flex items-center text-blue-600 hover:text-blue-800">
                            <i class="fab fa-github mr-2"></i>GitHub仓库
                        </a>
                        <a href="https://hub.docker.com/_/nginx" target="_blank" class="flex items-center text-blue-600 hover:text-blue-800">
                            <i class="fab fa-docker mr-2"></i>Docker镜像
                        </a>
                    </div>
                </div>
            </aside>

            <!-- Main Content Area -->
            <main class="flex-1">
                <!-- Overview Section -->
                <section id="overview" class="mb-16">
                    <h2 class="text-3xl font-bold mb-6 text-gray-800 border-b pb-2">Nginx概述</h2>
                    <div class="bg-white rounded-xl shadow-sm overflow-hidden mb-8">
                        <div class="p-6 md:p-8">
                            <div class="flex flex-col md:flex-row gap-8">
                                <div class="md:w-2/3">
                                    <p class="text-lg text-gray-700 mb-6">
                                        Nginx是一款高性能的开源Web服务器，也可以作为反向代理服务器、负载均衡器和HTTP缓存服务器使用。它是由俄罗斯的程序员Igor Sysoev编写的，首次发布于2004年。Nginx因其高性能、稳定性和丰富的功能而受到广泛欢迎，被用于许多大型的网站和Web应用程序中。
                                    </p>
                                    <div class="flex flex-wrap gap-4">
                                        <div class="flex items-center bg-blue-50 px-4 py-2 rounded-full">
                                            <i class="fas fa-bolt text-blue-500 mr-2"></i>
                                            <span class="text-sm font-medium text-gray-700">高性能</span>
                                        </div>
                                        <div class="flex items-center bg-blue-50 px-4 py-2 rounded-full">
                                            <i class="fas fa-memory text-blue-500 mr-2"></i>
                                            <span class="text-sm font-medium text-gray-700">低内存消耗</span>
                                        </div>
                                        <div class="flex items-center bg-blue-50 px-4 py-2 rounded-full">
                                            <i class="fas fa-cubes text-blue-500 mr-2"></i>
                                            <span class="text-sm font-medium text-gray-700">模块化设计</span>
                                        </div>
                                    </div>
                                </div>
                                <div class="md:w-1/3">
                                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1708052196943-a8ce53eb-2d99-469b-8ce8-548ed4605755.png" 
                                         alt="Nginx Logo" 
                                         class="w-full h-auto rounded-lg object-cover shadow">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="mt-8 grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div class="bg-white rounded-xl shadow-sm overflow-hidden">
                            <div class="p-6">
                                <h3 class="text-xl font-semibold mb-4 text-gray-800">发展历程</h3>
                                <div class="space-y-6">
                                    <div class="timeline-item">
                                        <div class="timeline-dot">
                                            <i class="fas fa-rocket text-xs"></i>
                                        </div>
                                        <div class="timeline-content">
                                            <h4 class="font-medium text-gray-800">2004年</h4>
                                            <p class="text-gray-600">Nginx首次公开发布，由Igor Sysoev开发</p>
                                        </div>
                                    </div>
                                    <div class="timeline-item">
                                        <div class="timeline-dot">
                                            <i class="fas fa-chart-line text-xs"></i>
                                        </div>
                                        <div class="timeline-content">
                                            <h4 class="font-medium text-gray-800">2011年</h4>
                                            <p class="text-gray-600">Nginx公司成立，提供商业支持和服务</p>
                                        </div>
                                    </div>
                                    <div class="timeline-item">
                                        <div class="timeline-dot">
                                            <i class="fas fa-globe text-xs"></i>
                                        </div>
                                        <div class="timeline-content">
                                            <h4 class="font-medium text-gray-800">2019年</h4>
                                            <p class="text-gray-600">Nginx被F5 Networks以6.7亿美元收购</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="bg-white rounded-xl shadow-sm overflow-hidden">
                            <div class="p-6">
                                <h3 class="text-xl font-semibold mb-4 text-gray-800">市场占比</h3>
                                <div class="mermaid">
                                    pie
                                        title Web服务器市场份额
                                        "Nginx" : 35.2
                                        "Apache" : 31.4
                                        "IIS" : 15.8
                                        "其他" : 17.6
                                </div>
                                <p class="text-sm text-gray-500 mt-4">
                                    * 数据来源: Netcraft 2023年Web服务器调查报告
                                </p>
                            </div>
                        </div>
                    </div>
                </section>

                <!-- Features Section -->
                <section id="features" class="mb-16">
                    <h2 class="text-3xl font-bold mb-8 text-gray-800 border-b pb-2">Nginx的核心特点</h2>
                    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                        <div class="card bg-white rounded-xl shadow-sm overflow-hidden">
                            <div class="p-6">
                                <div class="feature-icon">
                                    <i class="fas fa-tachometer-alt"></i>
                                </div>
                                <h3 class="text-xl font-semibold mb-3 text-gray-800">高性能</h3>
                                <p class="text-gray-600">
                                    Nginx以其卓越的性能著称。它采用了事件驱动的异步非阻塞架构，能够处理大量并发连接而不会消耗过多的系统资源。
                                </p>
                            </div>
                        </div>
                        <div class="card bg-white rounded-xl shadow-sm overflow-hidden">
                            <div class="p-6">
                                <div class="feature-icon">
                                    <i class="fas fa-memory"></i>
                                </div>
                                <h3 class="text-xl font-semibold mb-3 text-gray-800">低内存消耗</h3>
                                <p class="text-gray-600">
                                    Nginx的内存消耗非常低，即使在高负载情况下也能保持较低的内存占用。
                                </p>
                            </div>
                        </div>
                        <div class="card bg-white rounded-xl shadow-sm overflow-hidden">
                            <div class="p-6">
                                <div class="feature-icon">
                                    <i class="fas fa-sync-alt"></i>
                                </div>
                                <h3 class="text-xl font-semibold mb-3 text-gray-800">热部署</h3>
                                <p class="text-gray-600">
                                    Nginx支持热部署，可以在不中断服务的情况下动态加载和卸载模块，方便运维管理。
                                </p>
                            </div>
                        </div>
                        <div class="card bg-white rounded-xl shadow-sm overflow-hidden">
                            <div class="p-6">
                                <div class="feature-icon">
                                    <i class="fas fa-puzzle-piece"></i>
                                </div>
                                <h3 class="text-xl font-semibold mb-3 text-gray-800">模块化设计</h3>
                                <p class="text-gray-600">
                                    Nginx的设计是模块化的，可以通过加载不同的模块来扩展其功能，例如HTTP代理、负载均衡、反向代理、SSL支持等。
                                </p>
                            </div>
                        </div>
                        <div class="card bg-white rounded-xl shadow-sm overflow-hidden">
                            <div class="p-6">
                                <div class="feature-icon">
                                    <i class="fas fa-shield-alt"></i>
                                </div>
                                <h3 class="text-xl font-semibold mb-3 text-gray-800">高可靠性</h3>
                                <p class="text-gray-600">
                                    Nginx具有出色的稳定性和可靠性，能够长时间运行而不会出现内存泄漏或崩溃现象。
                                </p>
                            </div>
                        </div>
                        <div class="card bg-white rounded-xl shadow-sm overflow-hidden">
                            <div class="p-6">
                                <div class="feature-icon">
                                    <i class="fas fa-sliders-h"></i>
                                </div>
                                <h3 class="text-xl font-semibold mb-3 text-gray-800">灵活性</h3>
                                <p class="text-gray-600">
                                    Nginx支持灵活的配置选项，可以根据具体需求进行定制和调整，适用于各种不同规模和类型的网站和应用。
                                </p>
                            </div>
                        </div>
                    </div>
                </section>

                <!-- Usage Section -->
                <section id="usage" class="mb-16">
                    <h2 class="text-3xl font-bold mb-8 text-gray-800 border-b pb-2">Nginx的主要用途</h2>
                    <div class="bg-white rounded-xl shadow-sm overflow-hidden mb-8">
                        <div class="p-6 md:p-8">
                            <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                                <div>
                                    <h3 class="text-xl font-semibold mb-4 text-gray-800">Web服务器</h3>
                                    <p class="text-gray-600 mb-6">
                                        Nginx作为Web服务器，能够快速地处理静态文件和动态请求，并且支持高并发的访问。
                                    </p>
                                    <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1698835450168-5af4d518-a930-4143-bc0b-f97174a941d6.png" 
                                         alt="Web服务器架构" 
                                         class="w-full h-auto rounded-lg object-cover shadow">
                                </div>
                                <div>
                                    <h3 class="text-xl font-semibold mb-4 text-gray-800">反向代理</h3>
                                    <p class="text-gray-600 mb-6">
                                        Nginx可以作为反向代理服务器，将客户端的请求转发到多个后端服务器上，实现负载均衡和高可用性。
                                    </p>
                                    <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1698835448728-dc295dcd-dcf9-4a2f-b12b-cff61b4e4beb.png" 
                                         alt="反向代理架构" 
                                         class="w-full h-auto rounded-lg object-cover shadow">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                        <div class="card bg-white rounded-xl shadow-sm overflow-hidden">
                            <div class="p-6">
                                <div class="text-blue-500 mb-3">
                                    <i class="fas fa-balance-scale-left text-2xl"></i>
                                </div>
                                <h3 class="text-xl font-semibold mb-3 text-gray-800">负载均衡</h3>
                                <p class="text-gray-600">
                                    Nginx支持多种负载均衡算法，可以均衡地分配请求到不同的后端服务器，提高系统的性能和稳定性。
                                </p>
                            </div>
                        </div>
                        <div class="card bg-white rounded-xl shadow-sm overflow-hidden">
                            <div class="p-6">
                                <div class="text-blue-500 mb-3">
                                    <i class="fas fa-database text-2xl"></i>
                                </div>
                                <h3 class="text-xl font-semibold mb-3 text-gray-800">HTTP缓存服务器</h3>
                                <p class="text-gray-600">
                                    Nginx可以作为HTTP缓存服务器，缓存静态文件和动态内容，减轻后端服务器的压力，提高网站的响应速度。
                                </p>
                            </div>
                        </div>
                        <div class="card bg-white rounded-xl shadow-sm overflow-hidden">
                            <div class="p-6">
                                <div class="text-blue-500 mb-3">
                                    <i class="fas fa-exchange-alt text-2xl"></i>
                                </div>
                                <h3 class="text-xl font-semibold mb-3 text-gray-800">反向代理缓存</h3>
                                <p class="text-gray-600">
                                    Nginx可以作为反向代理缓存服务器，将动态内容缓存起来，加快内容的访问速度，降低服务器的负载。
                                </p>
                            </div>
                        </div>
                    </div>
                </section>

                <!-- Proxy Section -->
                <section id="proxy" class="mb-16">
                    <h2 class="text-3xl font-bold mb-8 text-gray-800 border-b pb-2">代理机制</h2>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                        <div>
                            <div class="bg-white rounded-xl shadow-sm overflow-hidden mb-6">
                                <div class="p-6">
                                    <h3 class="text-xl font-semibold mb-4 text-gray-800">正向代理</h3>
                                    <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1698835448285-90816575-0462-463d-8d1b-79447dd57402.png" 
                                         alt="正向代理图示" 
                                         class="w-full h-auto rounded-lg object-cover shadow mb-4">
                                    <p class="text-gray-600 mb-4">
                                        正向代理是给客户端做代理，客户端清楚要访问的目标服务器。
                                    </p>
                                    <div class="space-y-3">
                                        <div class="flex items-start">
                                            <div class="flex-shrink-0 h-6 w-6 rounded-full bg-blue-100 flex items-center justify-center mr-3 mt-0.5">
                                                <i class="fas fa-check text-blue-500 text-xs"></i>
                                            </div>
                                            <p class="text-gray-600">访问原来无法访问的资源</p>
                                        </div>
                                        <div class="flex items-start">
                                            <div class="flex-shrink-0 h-6 w-6 rounded-full bg-blue-100 flex items-center justify-center mr-3 mt-0.5">
                                                <i class="fas fa-check text-blue-500 text-xs"></i>
                                            </div>
                                            <p class="text-gray-600">用作缓存，加速访问速度</p>
                                        </div>
                                        <div class="flex items-start">
                                            <div class="flex-shrink-0 h-6 w-6 rounded-full bg-blue-100 flex items-center justify-center mr-3 mt-0.5">
                                                <i class="fas fa-check text-blue-500 text-xs"></i>
                                            </div>
                                            <p class="text-gray-600">对客户端访问授权，上网进行认证</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div>
                            <div class="bg-white rounded-xl shadow-sm overflow-hidden">
                                <div class="p-6">
                                    <h3 class="text-xl font-semibold mb-4 text-gray-800">反向代理</h3>
                                    <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1698835448728-dc295dcd-dcf9-4a2f-b12b-cff61b4e4beb.png" 
                                         alt="反向代理图示" 
                                         class="w-full h-auto rounded-lg object-cover shadow mb-4">
                                    <p class="text-gray-600 mb-4">
                                        反向代理给服务端做代理，客户端不知道要访问哪台服务器。
                                    </p>
                                    <div class="space-y-3">
                                        <div class="flex items-start">
                                            <div class="flex-shrink-0 h-6 w-6 rounded-full bg-blue-100 flex items-center justify-center mr-3 mt-0.5">
                                                <i class="fas fa-check text-blue-500 text-xs"></i>
                                            </div>
                                            <p class="text-gray-600">保护内网安全</p>
                                        </div>
                                        <div class="flex items-start">
                                            <div class="flex-shrink-0 h-6 w-6 rounded-full bg-blue-100 flex items-center justify-center mr-3 mt-0.5">
                                                <i class="fas fa-check text-blue-500 text-xs"></i>
                                            </div>
                                            <p class="text-gray-600">负载均衡</p>
                                        </div>
                                        <div class="flex items-start">
                                            <div class="flex-shrink-0 h-6 w-6 rounded-full bg-blue-100 flex items-center justify-center mr-3 mt-0.5">
                                                <i class="fas fa-check text-blue-500 text-xs"></i>
                                            </div>
                                            <p class="text-gray-600">缓存，减少服务器的压力</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="mt-8 bg-white rounded-xl shadow-sm overflow-hidden">
                        <div class="p-6">
                            <h3 class="text-xl font-semibold mb-4 text-gray-800">基于Nginx实现反向代理</h3>
                            <p class="text-gray-600 mb-6">
                                以下是一个简单的Nginx反向代理配置示例，将请求代理到后端的Tomcat服务器：
                            </p>
                            <div class="code-block rounded-lg overflow-hidden">
                                <div class="code-lang">nginx</div>
                                <pre><code class="language-nginx"># 监听80端口
server {
  listen 80;
  server_name localhost;
  
  # 基于反向代理访问到Tomcat服务器
  location / {
    proxy_pass http://192.168.199.109:8081/;
  }
}</code></pre>
                            </div>
                        </div>
                    </div>
                </section>

                <!-- Load Balancing Section -->
                <section id="load-balancing" class="mb-16">
                    <h2 class="text-3xl font-bold mb-8 text-gray-800 border-b pb-2">负载均衡</h2>
                    <div class="bg-white rounded-xl shadow-sm overflow-hidden mb-8">
                        <div class="p-6 md:p-8">
                            <div class="mb-6">
                                <p class="text-gray-600 mb-4">
                                    将多个请求均匀的分配到多台服务器上，减轻每台服务器的压力，提高服务的吞吐量。
                                </p>
                                <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1708053220533-441a2b76-79a2-4d92-9d2e-4a70dda6bf24.png" 
                                     alt="负载均衡图示" 
                                     class="w-full h-auto rounded-lg object-cover shadow">
                            </div>
                            
                            <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                                <div class="card bg-white rounded-lg shadow-sm border border-gray-100">
                                    <div class="p-6">
                                        <h3 class="text-lg font-semibold mb-3 text-gray-800">轮询 (Round Robin)</h3>
                                        <p class="text-gray-600 mb-4">
                                            将客户端发起的请求，平均的分配给每一台服务器
                                        </p>
                                        <div class="code-block rounded-lg overflow-hidden">
                                            <div class="code-lang">nginx</div>
                                            <pre><code class="language-nginx">upstream backend {
  server 192.168.1.100;
  server 192.168.1.101;
}</code></pre>
                                        </div>
                                    </div>
                                </div>
                                <div class="card bg-white rounded-lg shadow-sm border border-gray-100">
                                    <div class="p-6">
                                        <h3 class="text-lg font-semibold mb-3 text-gray-800">加权轮询 (Weighted)</h3>
                                        <p class="text-gray-600 mb-4">
                                            根据服务器权重值不同，分配不同数量的请求
                                        </p>
                                        <div class="code-block rounded-lg overflow-hidden">
                                            <div class="code-lang">nginx</div>
                                            <pre><code class="language-nginx">upstream backend {
  server 192.168.1.100 weight=5;
  server 192.168.1.101 weight=1;
}</code></pre>
                                        </div>
                                    </div>
                                </div>
                                <div class="card bg-white rounded-lg shadow-sm border border-gray-100">
                                    <div class="p-6">
                                        <h3 class="text-lg font-semibold mb-3 text-gray-800">IP Hash</h3>
                                        <p class="text-gray-600 mb-4">
                                            基于客户端IP进行哈希，同一IP的请求总是发给同一服务器
                                        </p>
                                        <div class="code-block rounded-lg overflow-hidden">
                                            <div class="code-lang">nginx</div>
                                            <pre><code class="language-nginx">upstream backend {
  ip_hash;
  server 192.168.1.100;
  server 192.168.1.101;
}</code></pre>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="bg-white rounded-xl shadow-sm overflow-hidden">
                        <div class="p-6">
                            <h3 class="text-xl font-semibold mb-4 text-gray-800">负载均衡算法比较</h3>
                            <div class="mermaid">
                                graph TD
                                    A[负载均衡算法] --> B[轮询]
                                    A --> C[加权轮询]
                                    A --> D[IP Hash]
                                    A --> E[Fair]
                                    B --> F[平均分配请求]
                                    C --> G[按权重比例分配]
                                    D --> H[同一IP固定服务器]
                                    E --> I[按响应时间智能分配]
                            </div>
                        </div>
                    </div>
                </section>

                <!-- Static & Dynamic Separation Section -->
                <section id="static-dynamic" class="mb-16">
                    <h2 class="text-3xl font-bold mb-8 text-gray-800 border-b pb-2">动静分离</h2>
                    <div class="bg-white rounded-xl shadow-sm overflow-hidden mb-8">
                        <div class="p-6 md:p-8">
                            <div class="mb-6">
                                <p class="text-gray-600 mb-4">
                                    动静分离是指在web服务器架构中，将静态页面与动态页面或者静态内容接口和动态内容接口分开不同系统访问的架构设计方法，进而提升整个服务访问性能和可维护性。
                                </p>
                                <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1708053144047-eb3f95b1-47a9-4be4-83da-7775baac1684.png" 
                                     alt="动静分离图示" 
                                     class="w-full h-auto rounded-lg object-cover shadow">
                            </div>
                            
                            <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                                <div>
                                    <h3 class="text-xl font-semibold mb-4 text-gray-800">动态资源代理</h3>
                                    <p class="text-gray-600 mb-4">
                                        使用proxy_pass动态代理到后端应用服务器
                                    </p>
                                    <div class="code-block rounded-lg overflow-hidden">
                                        <div class="code-lang">nginx</div>
                                        <pre><code class="language-nginx">location /api {
  proxy_pass http://backend-server;
}</code></pre>
                                    </div>
                                </div>
                                <div>
                                    <h3 class="text-xl font-semibold mb-4 text-gray-800">静态资源代理</h3>
                                    <p class="text-gray-600 mb-4">
                                        使用root或alias直接服务静态文件
                                    </p>
                                    <div class="code-block rounded-lg overflow-hidden">
                                        <div class="code-lang">nginx</div>
                                        <pre><code class="language-nginx">location /static {
  root /data/www;
  expires 30d;
}</code></pre>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="bg-white rounded-xl shadow-sm overflow-hidden">
                        <div class="p-6">
                            <h3 class="text-xl font-semibold mb-4 text-gray-800">root与alias指令区别</h3>
                            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                                <div>
                                    <h4 class="font-medium text-gray-700 mb-2">alias示例</h4>
                                    <div class="code-block rounded-lg overflow-hidden">
                                        <div class="code-lang">nginx</div>
                                        <pre><code class="language-nginx">location /img/ {
  alias /var/www/image/;
}</code></pre>
                                    </div>
                                    <p class="text-sm text-gray-500 mt-2">
                                        访问/img/时，nginx会去/var/www/image/目录找文件
                                    </p>
                                </div>
                                <div>
                                    <h4 class="font-medium text-gray-700 mb-2">root示例</h4>
                                    <div class="code-block rounded-lg overflow-hidden">
                                        <div class="code-lang">nginx</div>
                                        <pre><code class="language-nginx">location /img/ {
  root /var/www/image;
}</code></pre>
                                    </div>
                                    <p class="text-sm text-gray-500 mt-2">
                                        访问/img/时，nginx会去/var/www/image/img/目录找文件
                                    </p>
                                </div>
                            </div>
                            <div class="mt-4 p-4 bg-yellow-50 rounded-lg">
                                <div class="flex">
                                    <div class="flex-shrink-0">
                                        <i class="fas fa-exclamation-triangle text-yellow-400"></i>
                                    </div>
                                    <div class="ml-3">
                                        <p class="text-sm text-yellow-700">
                                            <strong>重要区别：</strong> alias后面必须要用"/"结束，否则会找不到文件。而root则可有可无。
                                        </p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>

                <!-- High Availability Section -->
                <section id="ha" class="mb-16">
                    <h2 class="text-3xl font-bold mb-8 text-gray-800 border-b pb-2">高可用方案</h2>
                    <div class="bg-white rounded-xl shadow-sm overflow-hidden mb-8">
                        <div class="p-6 md:p-8">
                            <h3 class="text-xl font-semibold mb-4 text-gray-800">什么是高可用？</h3>
                            <p class="text-gray-600 mb-6">
                                高可用HA（High Availability）是分布式系统架构设计中必须考虑的因素之一，它通常是指通过设计减少系统不能提供服务的时间。假设系统一直能够提供服务，我们说系统的可用性是100%。如果系统每运行100个时间单位，会有1个时间单位无法提供服务，我们说系统的可用性是99%。很多公司的高可用目标是4个9，也就是99.99%，这就意味着系统的年停机时间为8.76个小时。
                            </p>
                            <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1698835452111-b4eb696e-4fa2-4cc9-aff3-c213e39c8962.png" 
                                 alt="高可用图示" 
                                 class="w-full h-auto rounded-lg object-cover shadow mb-6">
                            
                            <h3 class="text-xl font-semibold mb-4 text-gray-800">Nginx高可用架构</h3>
                            <p class="text-gray-600 mb-6">
                                Nginx高可用通常采用主备模式结合Keepalived实现：
                            </p>
                            <div class="mermaid">
                                graph LR
                                    A[客户端] --> B[虚拟IP]
                                    B --> C[主Nginx]
                                    B --> D[备Nginx]
                                    C --> E[后端服务器]
                                    D --> E
                            </div>
                        </div>
                    </div>

                    <div class="bg-white rounded-xl shadow-sm overflow-hidden">
                        <div class="p-6">
                            <h3 class="text-xl font-semibold mb-4 text-gray-800">Keepalived配置示例</h3>
                            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                                <div>
                                    <h4 class="font-medium text-gray-700 mb-2">主服务器配置</h4>
                                    <div class="code-block rounded-lg overflow-hidden">
                                        <div class="code-lang">nginx</div>
                                        <pre><code class="language-nginx">vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    virtual_ipaddress {
        192.168.1.100
    }
}</code></pre>
                                    </div>
                                </div>
                                <div>
                                    <h4 class="font-medium text-gray-700 mb-2">备服务器配置</h4>
                                    <div class="code-block rounded-lg overflow-hidden">
                                        <div class="code-lang">nginx</div>
                                        <pre><code class="language-nginx">vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 90
    advert_int 1
    virtual_ipaddress {
        192.168.1.100
    }
}</code></pre>
                                    </div>
                                </div>
                            </div>
                            <div class="mt-6 p-4 bg-blue-50 rounded-lg">
                                <h4 class="font-medium text-blue-800 mb-2">Nginx健康检查脚本</h4>
                                <div class="code-block rounded-lg overflow-hidden">
                                    <div class="code-lang">bash</div>
                                    <pre><code class="language-bash">#!/bin/bash
A=`ps -C nginx --no-header |wc -l`        
if [ $A -eq 0 ];then                        
    systemctl start nginx                
    if [ `ps -C nginx --no-header |wc -l` -eq 0 ];then
        killall keepalived
    fi
fi</code></pre>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>

                <!-- Process Model Section -->
                <section id="process-model" class="mb-16">
                    <h2 class="text-3xl font-bold mb-8 text-gray-800 border-b pb-2">Nginx进程模型</h2>
                    <div class="bg-white rounded-xl shadow-sm overflow-hidden">
                        <div class="p-6 md:p-8">
                            <div class="flex flex-col md:flex-row gap-8">
                                <div class="md:w-1/2">
                                    <h3 class="text-xl font-semibold mb-4 text-gray-800">Master-Worker架构</h3>
                                    <p class="text-gray-600 mb-6">
                                        Nginx启动成功默认会有两个进程，master和worker。master进程主要用来管理worker进程，而worker进程则负责处理实际的网络请求。
                                    </p>
                                    <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1698835453115-f4f82936-780e-41f6-a276-6bad66858e0e.png" 
                                         alt="Nginx进程模型" 
                                         class="w-full h-auto rounded-lg object-cover shadow">
                                </div>
                                <div class="md:w-1/2">
                                    <div class="mb-8">
                                        <h4 class="font-semibold text-lg mb-3 text-gray-800">Master进程职责</h4>
                                        <ul class="space-y-3">
                                            <li class="flex items-start">
                                                <div class="flex-shrink-0 h-6 w-6 rounded-full bg-blue-100 flex items-center justify-center mr-3">
                                                    <i class="fas fa-check text-blue-500 text-xs"></i>
                                                </div>
                                                <p class="text-gray-600">接收来自外界的信号</p>
                                            </li>
                                            <li class="flex items-start">
                                                <div class="flex-shrink-0 h-6 w-6 rounded-full bg-blue-100 flex items-center justify-center mr-3">
                                                    <i class="fas fa-check text-blue-500 text-xs"></i>
                                                </div>
                                                <p class="text-gray-600">向各worker进程发送信号</p>
                                            </li>
                                            <li class="flex items-start">
                                                <div class="flex-shrink-0 h-6 w-6 rounded-full bg-blue-100 flex items-center justify-center mr-3">
                                                    <i class="fas fa-check text-blue-500 text-xs"></i>
                                                </div>
                                                <p class="text-gray-600">监控worker进程的运行状态</p>
                                            </li>
                                            <li class="flex items-start">
                                                <div class="flex-shrink-0 h-6 w-6 rounded-full bg-blue-100 flex items-center justify-center mr-3">
                                                    <i class="fas fa-check text-blue-500 text-xs"></i>
                                                </div>
                                                <p class="text-gray-600">当worker进程异常退出时，自动重新启动新的worker进程</p>
                                            </li>
                                        </ul>
                                    </div>
                                    <div>
                                        <h4 class="font-semibold text-lg mb-3 text-gray-800">Worker进程职责</h4>
                                        <ul class="space-y-3">
                                            <li class="flex items-start">
                                                <div class="flex-shrink-0 h-6 w-6 rounded-full bg-blue-100 flex items-center justify-center mr-3">
                                                    <i class="fas fa-check text-blue-500 text-xs"></i>
                                                </div>
                                                <p class="text-gray-600">处理实际的网络请求</p>
                                            </li>
                                            <li class="flex items-start">
                                                <div class="flex-shrink-0 h-6 w-6 rounded-full bg-blue-100 flex items-center justify-center mr-3">
                                                    <i class="fas fa-check text-blue-500 text-xs"></i>
                                                </div>
                                                <p class="text-gray-600">采用异步非阻塞事件处理机制</p>
                                            </li>
                                            <li class="flex items-start">
                                                <div class="flex-shrink-0 h-6 w-6 rounded-full bg-blue-100 flex items-center justify-center mr-3">
                                                    <i class="fas fa-check text-blue-500 text-xs"></i>
                                                </div>
                                                <p class="text-gray-600">一个请求只在一个worker进程中处理</p>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
            </main>
        </div>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-lg font-medium text-white">技术小馆</h3>
                    <p class="mt-1 text-sm">分享前沿技术，探索无限可能</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition-colors">
                        <i class="fas fa-globe mr-1"></i> http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="mt-8 pt-8 border-t border-gray-800 text-center text-sm">
                <p>© 2023 技术小馆. 版权所有.</p>
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });

        // Smooth scrolling for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });

                // Update active nav link
                document.querySelectorAll('.nav-link').forEach(link => {
                    link.classList.remove('active');
                });
                this.classList.add('active');
            });
        });

        // Update active nav link on scroll
        window.addEventListener('scroll', function() {
            const sections = document.querySelectorAll('section');
            let currentSection = '';
            
            sections.forEach(section => {
                const sectionTop = section.offsetTop - 100;
                const sectionHeight = section.clientHeight;
                if (window.pageYOffset >= sectionTop) {
                    currentSection = section.getAttribute('id');
                }
            });
            
            document.querySelectorAll('.nav-link').forEach(link => {
                link.classList.remove('active');
                if (link.getAttribute('href') === `#${currentSection}`) {
                    link.classList.add('active');
                }
            });
        });
    </script>
</body>
</html>
```